package com.fr.report.web.ui.impl;

import com.fr.base.Inter;
import com.fr.base.core.json.JSONException;
import com.fr.base.core.json.JSONObject;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.report.web.ui.Button;
import com.fr.report.web.ui.Icon;
import com.fr.report.web.ui.IconManager;
import com.fr.report.web.ui.ToolBarMenuButton;
import com.fr.web.Repository;
import java.util.ArrayList;
import java.util.List;

public final class Print extends ToolBarMenuButton
{
  private boolean pdfPrint = true;
  private boolean appletPrint = true;
  private boolean flashPrint = true;
  private boolean serverPrint = false;

  public Print()
  {
    super(Inter.getLocText("Print"), IconManager.PRINT.getName());
  }

  public boolean isPDFPrint()
  {
    return this.pdfPrint;
  }

  public void setPDFPrint(boolean paramBoolean)
  {
    this.pdfPrint = paramBoolean;
  }

  public boolean isAppletPrint()
  {
    return this.appletPrint;
  }

  public void setAppletPrint(boolean paramBoolean)
  {
    this.appletPrint = paramBoolean;
  }

  public boolean isFlashPrint()
  {
    return this.flashPrint;
  }

  public void setFlashPrint(boolean paramBoolean)
  {
    this.flashPrint = paramBoolean;
  }

  public boolean isServerPrint()
  {
    return this.serverPrint;
  }

  public void setServerPrint(boolean paramBoolean)
  {
    this.serverPrint = paramBoolean;
  }

  public Button[] createMenuItems()
  {
    ArrayList localArrayList = new ArrayList();
    if (this.pdfPrint)
      localArrayList.add(new PDFPrint());
    if (this.appletPrint)
      localArrayList.add(new AppletPrint());
    if (this.flashPrint)
      localArrayList.add(new FlashPrint());
    if (this.serverPrint)
      localArrayList.add(new ServerPrint());
    return ((Button[])localArrayList.toArray(new Button[localArrayList.size()]));
  }

  protected JSONObject createChildConfig(Repository paramRepository)
    throws JSONException
  {
    JSONObject localJSONObject = super.createChildConfig(paramRepository);
    localJSONObject.put("appletPrint", isAppletPrint());
    localJSONObject.put("pdfPrint", isPDFPrint());
    localJSONObject.put("flashPrint", isFlashPrint());
    localJSONObject.put("serverPrint", isServerPrint());
    return localJSONObject;
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    super.readXML(paramXMLableReader);
    if ((paramXMLableReader.isChildNode()) && (paramXMLableReader.getTagName().equals("PrintButtons")))
    {
      String str;
      if ((str = paramXMLableReader.getAttr("pdfPrint")) != null)
        setPDFPrint(Boolean.valueOf(str).booleanValue());
      if ((str = paramXMLableReader.getAttr("appletPrint")) != null)
        setAppletPrint(Boolean.valueOf(str).booleanValue());
      if ((str = paramXMLableReader.getAttr("flashPrint")) != null)
        setFlashPrint(Boolean.valueOf(str).booleanValue());
      if ((str = paramXMLableReader.getAttr("serverPrint")) != null)
        setServerPrint(Boolean.valueOf(str).booleanValue());
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    super.writeXML(paramXMLPrintWriter);
    paramXMLPrintWriter.startTAG("PrintButtons");
    if (!(this.pdfPrint))
      paramXMLPrintWriter.attr("pdfPrint", this.pdfPrint);
    if (!(this.appletPrint))
      paramXMLPrintWriter.attr("appletPrint", this.appletPrint);
    if (!(this.flashPrint))
      paramXMLPrintWriter.attr("flashPrint", this.flashPrint);
    if (this.serverPrint)
      paramXMLPrintWriter.attr("serverPrint", this.serverPrint);
    paramXMLPrintWriter.end();
  }

  public boolean equals(Object paramObject)
  {
    if ((paramObject == null) || (!(paramObject instanceof Print)))
      return false;
    Print localPrint = (Print)paramObject;
    return ((super.equals(paramObject)) && (isAppletPrint() == localPrint.isAppletPrint()) && (isFlashPrint() == localPrint.isPDFPrint()) && (isPDFPrint() == localPrint.isPDFPrint()) && (isServerPrint() == localPrint.isServerPrint()));
  }
}